<!--suppress ALL-->
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('参试设备列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>设备名称：</label>
                                <input type="text" name="examinationName" placeholder="请输入要搜索的设备名称"/>
                            </li>
                            <li>
                                <label>创建人：</label>
                                <input type="text" name="userName" placeholder="请输入要搜索的创建人"/>
                            </li>
                            <li>
                                <label>设备型号：</label>
                                <select name="examinationType" th:with="type=${@dict.getType('examination_type')}">
                                    <option value="">请选择要查询的设备型号</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>设备状态：</label>
                                <select name="examinationStatus" th:with="type=${@dict.getType('examination_status')}">
                                    <option value="">请选择要查询的设备状态</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>使用状态：</label>
                                <select name="useStatus" th:with="type=${@dict.getType('examination_use_status')}">
                                    <option value="">请选择要查询设备的使用状态</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="examination:examination:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="examination:examination:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="examination:examination:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="examination:examination:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var viewFlag = [[${@permission.hasPermi('examination:examination:view')}]];
        var outboundFlag = [[${@permission.hasPermi('examination:examination:outbound')}]];
        var entranceFlag = [[${@permission.hasPermi('examination:examination:entrance')}]];
        var inputFlag = [[${@permission.hasPermi('examination:examination:input')}]];
        var outFlag = [[${@permission.hasPermi('examination:examination:out')}]];
        var editFlag = [[${@permission.hasPermi('examination:examination:edit')}]];
        var removeFlag = [[${@permission.hasPermi('examination:examination:remove')}]];
        var examinationTypeDatas = [[${@dict.getType('examination_type')}]];
        var examinationStatusDatas = [[${@dict.getType('examination_status')}]];
        var useStatusDatas = [[${@dict.getType('examination_use_status')}]];
        var prefix = ctx + "examination/examination";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                viewUrl: prefix + "/view/{id}",
                entranceUrl: prefix + "/entrance/{id}",
                inputUrl: prefix + "/input",
                outUrl: prefix + "/out",
                updateUrl: prefix + "/edit/{id}",
                outboundUrl: prefix + "/outbound",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "参试设备",
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'examinationId',
                        title: '设备编号'
                    },
                    {
                        field: 'examinationName',
                        title: '设备名称'
                    },
                    {
                        field: 'storeroomName',
                        title: '存放位置'
                    },
                    {
                        field: 'examinationType',
                        title: '设备型号',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(examinationTypeDatas, value);
                        }
                    },
                    {
                        field: 'userName',
                        title: '创建人'
                    },
                    {
                        field: 'createTime',
                        title: '创建时间'
                    },
                    {
                        field: 'examinationStatus',
                        title: '设备状态',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(examinationStatusDatas, value);
                        }
                    },
                    {
                        field: 'useStatus',
                        title: '使用状态',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(useStatusDatas, value);
                        }
                    },
                    {
                        title: '设备操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs ' + entranceFlag + '" href="javascript:void(0)" onclick="$.operate.entrance(\'' + row.examinationId + '\')"><i class="fa"></i>申请入场</a> ');

                            var actions1 = [];
                            actions1.push('<a class="btn btn-success btn-xs ' + outFlag + '" href="javascript:void(0)" onclick="$.operate.out(\'' + row.examinationId + '\')"><i class="fa"></i>申请离场</a> ');
                            actions1.push('<a class="btn btn-success btn-xs ' + outboundFlag + '" href="javascript:void(0)" onclick="$.operate.outbound(\'' + row.examinationId + '\')"><i class="fa fa-sign-out"></i>出库</a>');

                            var actions2 = [];
                            actions2.push('<a class="btn btn-success btn-xs ' + outFlag + '" href="javascript:void(0)" onclick="$.operate.out(\'' + row.examinationId + '\')"><i class="fa"></i>申请离场</a> ');
                            actions2.push('<a class="btn btn-success btn-xs ' + inputFlag + '" href="javascript:void(0)" onclick="$.operate.input1(\'' + row.examinationId + '\')"><i class="fa fa-sign-in"></i>入库</a>');

                            var actions3 = [];
                            actions3.push('<a class="btn btn-success btn-xs ' + viewFlag + '" href="javascript:void(0)"><i class=""></i>试验完毕</a> ');

                            if ((row.storeroomName == null || row.storeroomName == '') && row.examinationStatus == 0 && row.useStatus == 0) {
                                return actions.join('');
                            }else if ((row.storeroomName != null || row.storeroomName != '') && row.examinationStatus == 1 && row.useStatus == 0) {
                                return actions1.join('');
                            }else if ((row.storeroomName != null || row.storeroomName != '') && row.examinationStatus == 1 && row.useStatus == 1) {
                                return actions2.join('');
                            }else if ((row.storeroomName == null || row.storeroomName == '') && row.examinationStatus == 2 && row.useStatus == 1) {
                                return actions3.join('');
                            }

                        }
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + viewFlag + '" href="javascript:void(0)" onclick="$.operate.view(\'' + row.examinationId + '\')"><i class="fa fa-search"></i>查看</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.examinationId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.examinationId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>